package com.jsh.erp.controller;

import com.jsh.erp.datasource.entities.Attachment;
import com.jsh.erp.datasource.entities.Depot;
import com.jsh.erp.service.attachment.AttachmentService;
import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.ErpInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Api(tags = {"附件"})
@RestController
@RequestMapping(value = "/attachment")
public class AttachmentController {

    @Resource
    private AttachmentService attachmentService;

    @GetMapping(value = "/getAttachmentListById")
    @ApiOperation(value = "根据单据id获取附件")
    public BaseResponseInfo getAttachmentListById(@RequestParam("id") String id,
                                                  HttpServletRequest request) throws Exception {
        List<Attachment> depotList = attachmentService.getAttachmentListById(id);
        return new BaseResponseInfo(ErpInfo.OK.code, depotList);
    }
}
